package io.bluerain.fragment.ui;

import android.app.Activity;
import android.os.Bundle;

import io.bluerain.fragment.R;

/**
 * 主Activity
 *
 * @author ccf
 */
public class MainActivity extends Activity implements BookListFragment.Callback {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
    }

    @Override
    public void onItemSelected(Integer id) {
        //创建Bundle，给Fragment传递参数
        Bundle bundle = new Bundle();
        bundle.putInt(BookDetailFragment.ITEM_ID, id);
        BookDetailFragment fragment = new BookDetailFragment();
        fragment.setArguments(bundle);//设置参数
        getFragmentManager().beginTransaction()
                .replace(R.id.book_detail_container, fragment)
                .commit();//替换fragment
    }


}